home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: [Q] how to specify binary values
- Date: Wed, 27 Mar 96 20:53:36 GMT
- Organization: none
- Message-ID: <827960016snz@genesis.demon.co.uk>
- References: <4ihqi0$9mt@brain.npiec.on.ca> <4isvnd$jkf@newshost.cyberramp.net> <4j4li6INNmbf@duncan.cs.utk.edu> <4j646k$ad0@news.xs4all.nl>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4j646k$ad0@news.xs4all.nl> falstaff@xs4all.nl "Falstaff" writes:
-
- ...
-
- >>#define BINARY_NUM32(xx_d31,xx_d30, xx_d29,xx_d28,xx_d27,xx_d26,xx_d25,xx_d24,>xx_d23,xx_d22,xx_d21,xx_d20, xx_d19,xx_d18,xx_d17,xx_d16,xx_d15,xx_d14,xx_d13,
- >xx_d12,xx_d11,xx_d10, xx_d9,xx_d8,xx_d7,xx_d6,xx_d5,xx_d4,xx_d3,xx_d2,xx_d1,
- >xx_d0) \
- >> ((BINARY_NUM16(xx_d31,xx_d30, xx_d29,xx_d28,xx_d27,xx_d26,
- ^
- (long)
-
-
- >xx_d25, \
- >> xx_d24,xx_d23,xx_d22,xx_d21,xx_d20,xx_d19,xx_d18,xx_d17,xx_d16) <<
- > 16) | \
- > ^^
- > Actually I think you better use 16L here
-
- >> and << perform the integral promotions independently on each operand unlike,
- for example, + which performs the usual arithmetic conversions (i.e. combining
- types from both operands). So this doesn't force the left hand operand (or
- indeed the result of << ) to be promoted to long. You need an explicit cast
- where I have indicated instead.
-
- >> BINARY_NUM16( xx_d15,xx_d14,xx_d13,xx_d12,xx_d11,xx_d10, \
- >> xx_d9,xx_d8,xx_d7,xx_d6,xx_d5,xx_d4,xx_d3,xx_d2,xx_d1,xx_d0))
- >>
- >> x = BINARY_NUM32(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,>1,1);
-
- >Please hold while I find a bag to vomit into...
- >
- >Thank you, I feel much better now.
- >
- >Pity K&R didn't think about 0b01020101.
-
- 2?
-
- Then of course there is the true horror of 64 bit systems (and beyond).
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-